//
//  SecondViewController.m
//  相册
//
//  Created by dllo on 16/6/14.
//  Copyright © 2016年 zuzhiming. All rights reserved.
//

#import "SecondViewController.h"
#import "CustomScrollView.h"
@interface SecondViewController ()
@property (nonatomic, retain) CustomScrollView *customScrollView;


@end

@implementation SecondViewController

- (void)dealloc
{
    [_customScrollView release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //自动调整ScrollViewInsets 默认是开始起的  改成NO不允许系统自动调整
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self createCustomScrollView];
    
    [self DataHandle];
    
    [self createGoBackBarButton];
    
}

//创建自定义滚动视图
- (void)createCustomScrollView
{
    self.customScrollView = [[CustomScrollView alloc] initWithFrame:CGRectMake(0, 128, self.view.bounds.size.width, 240)];
    
    //被push进来的时候传入前一页的tag值
    [self.customScrollView changeScrollViewContentOffSet:_number];
    
    [self.view addSubview:_customScrollView];
    
    [_customScrollView release];
}

//准备数据
- (void)DataHandle
{
//    NSMutableArray *dataArray = [NSMutableArray array];
//    for (NSInteger i = 1; i <= 6; i++) {
//        NSString *imagePath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%ld", i] ofType:@"jpg"];
//        UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
//        [dataArray addObject:image];
//}
    self.customScrollView.imageArray = self.imageArray;
    
  
}

- (void)createGoBackBarButton
{
    UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(didClickedGoBackButton:)];
    self.navigationItem.leftBarButtonItem = back;
    
}

- (void)didClickedGoBackButton:(UIBarButtonItem *)button
{
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)viewWillAppear:(BOOL)animated
{
    self.navigationItem.hidesBackButton = YES;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
